package com.cysion.study.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.cysion.other._setOnClickListener
import com.cysion.study.R
import com.cysion.study.entity.XitiListEntity
import com.cysion.study.ktbox.base.BaseAdapter
import com.cysion.study.ktbox.base.BaseViewHolder
import kotlinx.android.synthetic.main.item_choose_ti_list.view.*

class ChooseTiListAdapter(mEntities: MutableList<XitiListEntity>, mContext: Context) :
    BaseAdapter<XitiListEntity>(mEntities, mContext) {

    companion object {

        //点击事件
        const val preview = 2000
        const val refuse = 2001
        const val agree = 2003
    }

    override fun onCreateViewHolder(
        parent: ViewGroup,
        viewType: Int
    ): BaseViewHolder<XitiListEntity> {
        return ProMoneyHolder(
            LayoutInflater.from(mContext).inflate(R.layout.item_choose_ti_list, parent, false)
        )
    }

    class ProMoneyHolder(itemView: View) : BaseViewHolder<XitiListEntity>(itemView) {
        override fun fillData(obj: XitiListEntity, position: Int) {
            itemView?.apply {
                //type:String//":1//习题类型 1、单选；2、多选；3、解答题；4、判断题
                if (obj.type == "1") {
                    itemView.tv_name.text = obj.title + "(单选题)"
                } else if (obj.type == "2") {
                    itemView.tv_name.text = obj.title + "(多选题)"
                } else if (obj.type == "3") {
                    itemView.tv_name.text = obj.title + "(解答题)"
                } else if (obj.type == "4") {
                    itemView.tv_name.text = obj.title + "(判断题)"
                }

                itemView.tv_look._setOnClickListener {
                    mOnTypeClickListener?.invoke(obj, position, preview)
                }

            }
        }

    }
}